Skip to content

Set panel title/aspect/frameon once per panel, not per render command#702

Open
timtreis wants to merge 1 commit into
mainfrom
fix/issue-695-title-per-panel
Open

Set panel title/aspect/frameon once per panel, not per render command#702
timtreis wants to merge 1 commit into
mainfrom
fix/issue-695-title-per-panel

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented Jun 7, 2026

Summary

Fixes #695. In PlotAccessor.show, the panel title / set_aspect("equal") / axis("off") block sat inside the for cmd, params in render_cmds: loop (basic.py:~1797), so it ran once per render command instead of once per panel.

For a chained call like render_images().pl.render_shapes(...), ax.set_title(...)/set_aspect/axis("off") executed N times per panel, and the title-length IndexError check re-evaluated each iteration — so a mismatched title length could surface mid-render rather than up front.

Fix

Dedent the block one level so it runs once per panel, after the per-command loop. That's the entire change — Python's indentation moves it out of the inner loop; it already uses only panel-level locals (title, panel_key, cs, i, ax, fig_params).

Verification

  • Byte-identical to main (RGBA buffers compared via np.array_equal) for a single-command plot and a 3-command chain with title= and frameon=False set — the calls are idempotent, so output is unchanged.
  • Non-visual suite: 368 passed, 1 skipped.
  • pre-commit: ruff + mypy pass.

No regression test added: the change removes redundant repeated calls with no observable output difference, so there's no new behavior to lock that the existing multi-panel-title visual tests (CI) don't already cover.

Note / possible follow-up

The issue also suggested validating len(title) == num_panels once before the panel loop. That's left out here to keep the diff minimal — the per-panel IndexError still fires (now once per panel). Happy to add the up-front validation if preferred.

…#695)

In `show()`, the title/`set_aspect`/`axis("off")` block sat inside the
`for cmd, params in render_cmds:` loop, so for a chained call (e.g.
render_images().render_shapes()) these ran once per render command instead of
once per panel, and the title-length `IndexError` check re-evaluated each
iteration (so it could surface mid-loop rather than up front).

Dedent the block one level so it runs once per panel after the per-command
loop. Output is unchanged (the calls are idempotent) — verified byte-identical
to main for single- and multi-command chains with title and frameon set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

show(): title/aspect/frameon set once per render-command instead of once per panel

1 participant